package com.twotigers.tenthpower.recruit.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.twotigers.tenthpower.recruit.entity.EnterpriseEntity;
import com.twotigers.tenthpower.recruit.service.EnterpriseService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 企业
 *
 * @author Erhu
 * @email 1935417243@qq.com
 * @date 2021-03-04 15:59:14
 */
@RestController
@RequestMapping("recruit/enterprise")
public class EnterpriseController {
    @Autowired
    private EnterpriseService enterpriseService;

    /**
     * 列表
     */
    @GetMapping
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = enterpriseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		EnterpriseEntity enterprise = enterpriseService.getById(id);

        return R.ok().put("enterprise", enterprise);
    }

    /**
     * 保存
     */
    @PostMapping ("/save")
    public R save(@RequestBody EnterpriseEntity enterprise){
		enterpriseService.save(enterprise);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody EnterpriseEntity enterprise){
		enterpriseService.updateById(enterprise);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] ids){
		enterpriseService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
